import { Component, OnInit } from '@angular/core';
import { AccountService } from 'src/app/service/account.service';
import { TimeDetailService } from 'src/app/service/time-detail.service';

@Component({
  selector: 'app-time-detail',
  templateUrl: './time-detail.component.html',
  styleUrls: ['./time-detail.component.less']
})
export class TimeDetailComponent implements OnInit {

  datalist: any[] | null = null;
  types: any[] | null = null;
  isLoading: boolean = false;
  totalCount: number;
  selectData: any = {
    //style: 'out',
    pagesize: 10,
    pageindex: 1
  }

  getType() {
    this.isLoading = true;
    this.timeDetailService.allType().subscribe(result => {
      this.isLoading = false;
      this.types = result['data'];
    });
  }

  getlist() {
    this.isLoading = true;
    this.timeDetailService.page(this.selectData).subscribe(result => {
      this.isLoading = false;
      this.totalCount = result['data']['count'];
      this.datalist = result['data']['items'];
    });
  }


  constructor(
    private timeDetailService: TimeDetailService
  ) { }

  ngOnInit(): void {
    this.getType();
    this.getlist();
  }

}
